<template>
	<view  class="force-login-wrap">
		<view class="force-login__content y-f">
			<button class="cu-btn author-btn" @tap="getuserinfo" >立即登录</button>
		</view>
	</view>
</template>
<script>
import store from '@/config/store.js';
import Wechat from "@/utils/wechat.js";
import { mapMutations, mapActions, mapState } from 'vuex';
export default {
	computed: {
		
	},
	methods: {
		...mapActions(['setTokenAndBack']),
		async getuserinfo(e) {
			var that = this;
			uni.getUserProfile({
				desc:'请授权',
				success: (e) => {
					that.getToken(e);
				},
				fail:function(e){
					
				}
			})
		},
		async getToken(e){
			var wechat = new Wechat();
			this.$api.loadingMsg('正在登录');
			var tokenObj = await wechat.wxMiniProgramLogin(e);
			if(tokenObj)
			{
				this.$api.jwtToken('set',tokenObj);
				this.$api.navbackTo();
			}
		},
		closeAuth() {
			store.commit('showForceLogin', false);
		}
	}
};
</script>

<style lang="scss">
.force-login-wrap {
	position: fixed;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	z-index: 9999;
	top: 0;
	left: 0;
	//background: linear-gradient(180deg, rgba(239, 196, 128, 1) 0%, rgba(248, 220, 165, 1) 25%, rgba(255, 255, 255, 1) 98%);
	background: #FFFFFF;
	.force-login__content {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		
		.author-btn {
			width: 630rpx;
			height: 80rpx;
			background: $uni-btn-color;
			border-radius: 40rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: rgba(255, 255, 255, 1);
		}
	}
}
</style>
